# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
    File Name:  RedisHelper
    Author   :  wanwei1029
    Date     :  2018/9/30
    Desc     :
------------------------------------------------------------------------------
"""
import redis
import samp.samp_logging as sl

logger = sl.get_logger('RedisHelper')
REDIS_IP = "192.168.99.100"
REDIS_PORT = 6379
REDIS_DB = 0


class RedisHelper(object):
    def __init__(self):
        pool = redis.ConnectionPool(host=REDIS_IP, port=REDIS_PORT)
        self.__conn = redis.Redis(connection_pool=pool)
        self.channel = "monitor"

    def publish(self, msg):
        self.__conn.publish(self.channel, msg)
        return True

    def subscribe(self):
        pub = self.__conn.pubsub()
        pub.subscribe(self.channel)
        pub.parse_response()
        return pub


def samp():
    """
    """


if __name__ == '__main__':
    test_method = "samp"
    if test_method == "samp":
        samp()